<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="query">
				<el-form-item>
					<el-input v-model="query.keyWord" placeholder="请输入关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="search">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" label="序号" width="60">
			</el-table-column>
			<el-table-column prop="name" label="名称" width="200" >
			</el-table-column>
			<el-table-column prop="url" label="URL" width="200" >
			</el-table-column>
			<el-table-column prop="descs" label="描述" width="200" >
			</el-table-column>
			<el-table-column prop="sn" label="唯一标识" width="300" >
			</el-table-column>
			<el-table-column prop="parent.name" label="父权限" >
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination
          layout="prev, pager, next"
          @current-change="handleCurrentChange"
          :current-page="query.currentPage"
          :page-size="query.pageSize"
          :total="pageInfo.total"
          style="float:right;"
      >
			</el-pagination>
		</el-col>
    
	</section>
</template>

<script>
	export default {
		data() {
			return {
				listLoading: false,
				sels: [],//列表选中列
        query:{
          currentPage: 1,
          pageSize: 10,
          keyWord: ''
        },
        pageInfo:{
          total:0,
          rows:[]
        }
			}
		},
		methods: {
      search(){
        this.query.currentPage=1;
        this.getPermissions();
      },
			handleCurrentChange(val) {
				this.query.currentPage = val;
				this.getPermissions();
			},
			//获取用户列表
			getPermissions() {
				this.listLoading = true;
        this.$http.post("/permission",this.query)
            .then(result => {
              result = result.data;
              if (result.success){
                this.pageInfo = result.data;
                this.listLoading = false;
              }else {
                this.$message({message:result.message,type:"error"});
              }
            })
            .catch(result => {
              this.$message({message:"网络异常,请检查网络!",type:"error"});
            })
			},
			selsChange: function (sels) {
				this.sels = sels;
			}
		},
		mounted() {
			this.getPermissions();
		}
	}

</script>

<style scoped>

</style>